cmake_minimum_required(VERSION 3.0.2)
project(formation_avoidance)

set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -Wall -g")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -O3 -mtune=native ")
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
add_definitions(-std=c++11 -g -O3 -ftree-vectorize )

find_package(catkin REQUIRED COMPONENTS
  roscpp
  message_filters
  geometry_msgs
  sensor_msgs
  gazebo_msgs
  tf
  nav_msgs
  image_transport
  cv_bridge
  message_generation
  nlopt
  dynamic_reconfigure
  quadrotor_msgs

)
generate_dynamic_reconfigure_options(
		cfg/MyStuff.cfg
)


add_message_files(
  FILES
  DistributedOptimize.msg
  AstarPath.msg
  OptimizeTraj.msg
  OptimizeTrajExchange.msg
) 

generate_messages(
  DEPENDENCIES
  std_msgs
  geometry_msgs
  formation_avoidance
)

find_package(PythonLibs 2.7)
find_package(PCL REQUIRED)
find_package(OpenCV REQUIRED)
find_package(Eigen3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIRS})
include_directories(${PYTHON_INCLUDE_DIRS})
catkin_package( CATKIN_DEPENDS message_runtime)

include_directories(${PCL_INCLUDE_DIRS} ${catkin_INCLUDE_DIRS})
include_directories(${OpenCV_INCLUDE_DIRS})
include_directories(${PROJECT_SOURCE_DIR}/include)




add_library(formation_library STATIC src/formation.cpp src/distribute_optimizer.cpp src/utils.cpp include/bspline_cius/non_uniform_bspline_cius.cpp 
			src/FormationBsplineTrajectoryOptimize.cpp include/minimum_snap_path_plan/minimum_snap_path_plan.cpp src/Astar.cpp )
target_include_directories(formation_library PUBLIC  ${PROJECT_SOURCE_DIR}/include PRIVATE ${PYTHON_INCLUDE_DIRS})
target_link_libraries(formation_library ${PYTHON_LIBRARIES})

add_executable(agent0 src/agent0.cpp )
target_link_libraries(agent0 formation_library ${OpenCV_LIBS} ${PCL_LIBRARIES} ${catkin_LIBRARIES} )
add_dependencies(agent0 ${PROJECT_NAME}_gencfg)

add_executable(convert_pointcloud src/convert_pointcloud.cpp )
target_link_libraries(convert_pointcloud ${OpenCV_LIBS} ${PCL_LIBRARIES} ${catkin_LIBRARIES} )

add_executable(agent_exc src/agent_exc.cpp include/bspline_cius/non_uniform_bspline_cius.cpp )
target_link_libraries(agent_exc ${OpenCV_LIBS}  ${catkin_LIBRARIES} )

add_executable(formation_offb_mode_service src/formation_offb_mode_service.cpp )
target_link_libraries(formation_offb_mode_service ${catkin_LIBRARIES} )

add_executable(setStartButton src/setStartButton.cpp )
target_link_libraries(setStartButton ${catkin_LIBRARIES} )

add_executable(restart src/restart.cpp )
target_link_libraries(restart ${catkin_LIBRARIES} )

add_executable(test_bspline src/test_bspline.cpp )
target_link_libraries(test_bspline ${catkin_LIBRARIES} formation_library)

add_executable(simple_plot src/simple_plot.cpp )
target_link_libraries(simple_plot ${catkin_LIBRARIES} ${PYTHON_LIBRARIES} formation_library)

add_executable(formation_structure_test src/formation_structure_test.cpp )
target_link_libraries(formation_structure_test ${catkin_LIBRARIES} )
